<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/end.css" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<script>
			// 重写注入代码的方法，让注入代码使用此方法时出错
			String.fromCharCode = function(arg) {return true}
		</script>
	</head>
	<body>
		<div class="container" id="vue-qita">
			<!--头部-->
			<div class="top">
				<div class="left">
					<a href="javascript:" onclick="self.location=document.referrer;"><img src="img/back.png"><span>返回</span></a>
				</div>
				<div class="right">
					<span class="name"></span>
				</div>
				<div class="right">
					<a href="index.html?love2"><span>书城</span><img src="img/home.png"></a>
				</div>
			</div>
			<!--书籍图片，名称-->
			<div class="shu_state">
				<div class="tu"></div>
				<div class="intro_bookarck" @click="shou_search()" v-if="show">加入书架</div>
				<h4 class="h4_1">本书未完，作者还在努力码字中</h4>
				<h4 class="h4_2">敬请期待</h4>
			</div>
			<div class="qita">
				<div class="tit">
					<span>作者推荐</span>
					<span class="huan" @click="next_serach">换一换</span>
				</div>
				<!--推荐书籍-->
				<div>
					<div class="intro">
						<a :href="'book_details.html?id=' + books[0].ID">
							<div class="intro_tu">
								<img :src="init_image(books[0].Image)">
							</div>
							<div class="intro_right">
								<p class="intro_title">{{books[0].Title}}</p>
								<p class="intro_intro">{{books[0].Description}}</p>
								<span class="intro_fenlei">{{get_tag_name(books[0].TagID)}}</span>
							</div>
						</a>
					</div>
					<div class="content">
						<div>
							<a :href="'book_details.html?id=' + books[1].ID">
								<img :src="init_image(books[1].Image)">
							</a>
							<p>{{books[1].Title}}</p>
						</div>
						<div>
							<a :href="'book_details.html?id=' + books[2].ID">
								<img :src="init_image(books[2].Image)">
							</a>
							<p>{{books[2].Title}}</p>
						</div>
						<div>
							<a :href="'book_details.html?id=' + books[3].ID">
								<img :src="init_image(books[3].Image)">
							</a>
							<p>{{books[3].Title}}</p>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
	<script type="text/javascript" src="js/getUrlParam.js" ></script>
	<script type="text/javascript" src="js/vue.min.js"></script>
	<script type="text/javascript" src="js/local.js" ></script>
	<script>
//		var host = "http://wc.novel.orivil.com";
		var Finished=UrlParm.parm("Finished");
		var id=UrlParm.parm("id");
		if(Finished==1){
			$(".h4_1").html("本书已完结");
			$(".h4_2").html("更多小说等你看");
			$(".intro_bookarck").hide();
		}
		if(Finished==2){
			$(".h4_1").html("本书未完，作者还在努力码字中");
			$(".h4_2").html("敬请期待");
		}
		new Vue({
			el: "#vue-qita",
			data: {
				search: {
					Id:id,
					offset:0,
				},
				tags: [], // 所有的分类列表
				books: [], // 显示的图书列表
				show:true,
			},
			created: function() {
				let self = this;
				$.get(host + "/book-tags", function(data) {
					if(!!data.list) {
						self.tags = data.list;
					}
				})
				this.start_search();
				this.yinshou_search();
			},
			methods: {
				// 开始搜索
				start_search: function() {
					let self = this;
					this.books;
					let url = host + "/books?Limit=4&Offset="+self.search.offset;
					$.get(url, function(data) {
						if(!!data.list) {
								self.books = data.list;
						}
					})
				},
				shou_search: function() {
					let self = this;
					let url = host + "/bookmark?BookID="+self.search.Id;
					$.post(url)
					self.show = !self.show
					alert("添加成功!");
				},
				yinshou_search: function() {
					let self = this;
					let url = host + "/check-bookmark-exist?BookID="+self.search.Id;
					$.get(url, function(data) {
						if(!!data.exist) {
							if(data.exist==true){
								self.show = false;
							}
						}
					})
				},
				init_image: function(url) {
					return host + "/" + url
				},
				get_tag_name: function(tag_id) {
					for(let i = 0, ln = this.tags.length; i < ln; i++) {
						let tag = this.tags[i];
						if(tag.ID === tag_id) {
							return tag.Name
						}
					}
				},
				next_serach: function() {
					this.search.offset += 4;
					this.start_search();
				}
			}
		})
		$.ajax({
			type: "get",
			url: host + "/book-info?ID=" + id + "",
			datatype: "json",
			success: function(data) {
				if(!!data.book){
					var div = "";
					var name = data.book.Title;
					var Image = data.book.Image;
					div += '<img src="' + host + "/" + Image + '">' + '<p>' + name + '</p>';
					$(".name").html(name);
					$(".tu").html(div);
				}
				
			}
		})
		var m=8;
		var n=1;
		//美妙儿媳妇,稻香,她比烟花还耀眼,邪恶约定,交换温柔,芳芳,绝品少年
//		var arr=[["5323","1894141"],["7728","3469176"],["5321","1894066"],["5322","1894097"],["7625","3387566"],["7886","3609743"],["7883","3603016"]]
		
		//禁断之恋,夜色无边,嫂子的香味,心花怒放,女人如雾,风流奶爸,恋上女人花
		var arr=[["7873","3600049"],["7628","3388129"],["7868","3586132"],["7974","3678377"],["7328","2710773"],["7853","3574461"],["6501","2274898"]]
		var num = Math.floor(Math.random()*(m - n) + n);
//		console.log(num)
		function href(){
			window.location.href ="yuedu.html?id="+arr[num-1][0]+"&shu_head_id="+arr[num-1][1];
		}
		setTimeout('href()',1000)
	</script>
	<script>
		var _hmt = _hmt || [];
		(function() {
		  var hm = document.createElement("script");
		  hm.src = "https://hm.baidu.com/hm.js?055cff4356b44984f650fdfa60a0cee6";
		  var s = document.getElementsByTagName("script")[0]; 
		  s.parentNode.insertBefore(hm, s);
		})();
	</script>
</html>
